Skip to content

Adjusted regex to properly handle Windows paths #8518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 12, 2025

Conversation

N-Olbert
Copy link
Contributor

Summary of the changes (Less than 80 chars)

  • Fix Regex to consider Windows file path format

Closes #8517

@N-Olbert
Copy link
Contributor Author

N-Olbert commented Aug 10, 2025

Maybe adding something like

<PropertyGroup>
  <PathMap>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))=./</PathMap>
</PropertyGroup>

to Directory.Build.Props would also be an option. This would make the entire StackTraceHelper obsolete and all stack traces deterministic.

The output of FilterInputType_Should_ThrowException_WhenNoConventionIsRegisteredDefault with that setting is:

For more details look at the `Errors` property.

1. For more details look at the `Errors` property.

1. No default filter convention found. Call `AddFiltering()` on the schema builder.
 (HotChocolate.Types.ObjectType)

   at HotChocolate.Data.FilterDescriptorContextExtensions.<>c__DisplayClass1_0.<GetFilterConvention>b__0() in ./HotChocolate/Data/src/Data/Filters/Extensions/FilterDescriptorContextExtensions.cs:line 19
   at HotChocolate.Types.Descriptors.DescriptorContext.GetConventionOrDefault[T](Func`1 factory, String scope) in ./HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DescriptorContext.cs:line 165
   at HotChocolate.Data.FilterDescriptorContextExtensions.GetFilterConvention(IDescriptorContext context, String scope) in ./HotChocolate/Data/src/Data/Filters/Extensions/FilterDescriptorContextExtensions.cs:line 18
   at HotChocolate.Types.FilterObjectFieldDescriptorExtensions.<>c__DisplayClass5_0.<UseFiltering>b__1(IDescriptorContext c, ObjectFieldConfiguration definition) in ./HotChocolate/Data/src/Data/Filters/Extensions/FilterObjectFieldDescriptorExtensions.cs:line 128
   at HotChocolate.Types.Descriptors.DescriptorBase`1.<>c__DisplayClass21_0.<OnBeforeCreate>b__0(IDescriptorContext c, ITypeSystemConfiguration d) in ./HotChocolate/Core/src/Types/Types/Descriptors/DescriptorBase~1.cs:line 97
   at HotChocolate.Types.Descriptors.Configurations.OnCreateTypeSystemConfigurationTask.Configure(IDescriptorContext context) in ./HotChocolate/Core/src/Types/Types/Descriptors/Configurations/OnCreateTypeSystemConfigurationTask.cs:line 26
   at HotChocolate.Types.Descriptors.DescriptorBase`1.CreateConfiguration() in ./HotChocolate/Core/src/Types/Types/Descriptors/DescriptorBase~1.cs:line 57
   at HotChocolate.Types.Descriptors.ObjectTypeDescriptor.OnCreateConfiguration(ObjectTypeConfiguration definition) in ./HotChocolate/Core/src/Types/Types/Descriptors/ObjectTypeDescriptor.cs:line 94
   at HotChocolate.Types.Descriptors.DescriptorBase`1.CreateConfiguration() in ./HotChocolate/Core/src/Types/Types/Descriptors/DescriptorBase~1.cs:line 45
   at HotChocolate.Types.ObjectType.CreateConfiguration(ITypeDiscoveryContext context) in ./HotChocolate/Core/src/Types/Types/ObjectType.Initialization.cs:line 37
   at HotChocolate.Types.TypeSystemObject`1.Initialize(ITypeDiscoveryContext context) in ./HotChocolate/Core/src/Types/Types/TypeSystemObjectBase~1.cs:line 29
   at HotChocolate.Configuration.TypeRegistrar.InitializeType(TypeSystemObject typeSystemObject, String scope, Boolean isInferred) in ./HotChocolate/Core/src/Types/Configuration/TypeRegistrar.cs:line 177

I can provide a PR if requested

@glen-84
Copy link
Collaborator

glen-84 commented Aug 11, 2025

Hey @N-Olbert 👋

  1. I think that we could make the regex more simplistic, instead of special handling for Windows drives. For example, just in (.+):line (\d+)?
  2. Regarding the PathMap suggestion, it's interesting, but I'd be concerned that it might affect other components (PDBs, etc.) in unexpected ways, so maybe we should just use the regex for now?

@N-Olbert
Copy link
Contributor Author

N-Olbert commented Aug 11, 2025

Hey @glen-84

Indeed, the regex can be simplified. Anyway, the more I think about it, there might be some pretty obscure, highly theoretical cases where probably no regex will handle everything correctly (e.g., on Unix one could name a file foo:line 15\n.cs 🙃).

Anyways, I think switching to in (.+):line (\d+) is fine - especially since the code is covered by tests. I`ve updated the PR.

Regarding PathMap, I agree. A quick search showed that some projects use this - the biggest seems to be velopack - but that is not really an indicator. As there is no need for the change, we can just leave this as is. That beeing said, I dont think it will change something fundamental as the (real) paths of the build server most likely also don`t exist on the executing computer.

@glen-84 glen-84 merged commit 5a222a0 into ChilliCream:main Aug 12, 2025
108 checks passed
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (204d11d) to head (a8d0df6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #8518   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@glen-84
Copy link
Collaborator

glen-84 commented Aug 12, 2025

Thanks @N-Olbert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SchemaException: Stacktrace differs on Unix vs. Windows / Test failure on Windows
2 participants